package cn.zqy.demo.day08;

/** idCount必须为类变量，为成员变量，则会导致idCount的值从0开始，一直为1。。。 */
public class Student {
    // 根据new出来的对象个数，生成对应id
    private int id;
    private int age;
    private String name;
    public static String room;
    // private int idCount = 0;  /*错误的写法*/
    private static int idCount = 0;


    public Student() {
        this.id = ++idCount;
    }

    public Student(String name, int age) {
        this.id = ++idCount;
        this.age = age;
        this.name = name;
    }



    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

